package com.eastmoney.emis.edda.domain.valueobject;

/**
 * @description: Description
 * @projectName: EDDA-HSBC
 * @package: com.eastmoney.emis.edda.domain.valueobject
 * @author: 汪程程
 * @date: 2022/10/19 12:10 PM
 * @version: 1.0
 */
public enum MoneyType {
    CNY(0, "CNY"),
    USD(1, "USD"),
    HKD(2, "HKD");

    private Integer id;
    private String currency;

    MoneyType(Integer id, String currency) {
        this.id = id;
        this.currency = currency;
    }

    public Integer getId() {
        return id;
    }

    public String getCurrency() {
        return currency;
    }

    private static final MoneyType[] MONEY_TYPES = MoneyType.values();

    public static MoneyType parse(String currency) {
        for (MoneyType moneyType : MONEY_TYPES) {
            if (moneyType.currency.equals(currency)) {
                return moneyType;
            }
        }
        throw new IllegalArgumentException("unknown money_type:" + currency);
    }
}
